public class Test {
        public static int missingNumber(int[] nums) {
            int res = 0;
            for (int i = 0; i < nums.length; i++) {
                res ^= i;
                res ^= nums[i];
            }
            res ^= nums.length;

            return res;
        }

    public static void main(String[] args) {
        int[] nums = {0,1,3,4};
        int a = missingNumber(nums);
        System.out.println(a);
    }
}
